﻿using System.IO;
using System.Security;
using System.Text;
using mmGoogleDataProvider;
using NUnit.Framework;

namespace mmTests
{
    [TestFixture]
    public class TestGoogleProvider
    {
        [Test]
        public void TestGoogle1()
        {
            var gp = new GoogleDataProvider();
            var byteArray = Encoding.UTF8.GetBytes("foobar@gmail.com:password");
            var stream = new MemoryStream(byteArray);
            var movies = gp.ReadMovies(stream);
        }

        [Test]
        public void TestDecodingEncoding()
        {
            const string strIn = "Message to encode";
            var byteArray = Encoding.UTF8.GetBytes(strIn);
            var stream = new MemoryStream(byteArray);
            using (var estream = Gutils.EncodeStream(stream))
            {
                estream.Seek(0, SeekOrigin.Begin);
                var buff = new byte[estream.Length];
                estream.Read(buff, 0, (int) estream.Length);

                var ms = new MemoryStream(buff);

                using (var ds = Gutils.DecodeStream(ms))
                {
                    ds.Seek(0, SeekOrigin.Begin);
                    var db = new byte[ds.Length];
                    ds.Read(db, 0, (int)ds.Length);
                    var output = Encoding.UTF8.GetString(db);
                    Assert.AreEqual(strIn, output);
                }
            }
        }
    }
}
    